<?php

/**
 * CityBao (C)2010-2099 CityBao Inc.
 * This is NOT a freeware, use is subject to license terms
 *
 * Id:tools.php 2010-12-27 17:07:09
 */
if (!defined('CITY_BAO') || !defined('CB_ADMIN')) {
    exit('Access Denied');
}

if (!in_array($action, array('mailcheck'))) {
    show_message("没有此工具！");
}
if ($action == 'mailcheck') {
    $to = trim($request->getParam('testemail'));
    $param = $request->getParam('param');
    $config_core = array_merge($config_core, $param);
    if ($config_core['mailsend'] == 1) {
        $title = '标准方式发送 Email';
        $message = "通过 PHP 函数mail发送\n\n来自";
    } else {
        $title = '通过 SMTP 服务器(SOCKET)发送 Email';
        $message = "通过 SOCKET 连接 SMTP 服务器发送\n\n来自";
    }
    $title .=" @ ".date('Y-m-d H:i:s',TIME_STAMP);
    $message .= $config_core['sendemail_address'];
    $message .= "\n\n发送时间".date('Y-m-d H:i:s',TIME_STAMP);
    $result = send_mail($to, $title, $message);

    if ($result === true) {
        $alertmsg = '邮件发送成功:\n1 封标题为“' . $title . '”的测试邮件已经发出，请查收。';
    } else {
        $alertmsg = '邮件发送返回错误信息:\n'.$result;
    }

    echo '<script language="javascript">alert(\'' . str_replace(array('\'', "\n", "\r"), array('\\\'', '\n', ''), $alertmsg) . '\');</script>';
}